using System;
using MailClient.Handlers;
using MailClient.Data.IndexTables;
using Microsoft.Exchange.WebServices.Data;

namespace MailClient
{
	public class Test_Facade : MailEntry
	{
		public Test_Facade () {}
		public void RunMail(string FakeEmail)
		{
			ExchangeService fakeService = new ExchangeService();
			EmailMessage email = new EmailMessage(fakeService);
			email.Body = FakeEmail;
			email.Subject = String.Empty;
			//incoming = new Queue.IncomingRunner(email);
			//incoming.CommandComplete += new Queue.IncomingRunner.CommandCompleteHandler(incoming_CommandComplete);
			//incoming.Process();
		}

		private	void incoming_CommandComplete(MailClient.Queue.MessageEventArgs e)
		{
			//incoming.CommandComplete -= new Queue.IncomingRunner.CommandCompleteHandler(incoming_CommandComplete);
			if (e.Response.Contains("This message is Spam")) {
				SpamResult = true;
				SpamIndex.Index.Save();
			} else {
				SpamResult = false;
				NotSpamIndex.Index.Save();
			}
		}

		public bool SpamResult { get; private set;} 
	}
}

